package com.hejia.alauda.entity;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.joda.time.DateTime;

/**
 * 产品收益计算规则
 * 指定产品资产不同持有时间的年化利率，计算利率时根据资产的持有时间分别计算收益。
 * @author hyr
 *
 */
public class ProductEarningsRule extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7962931080599471969L;
	
	@Column
	@JsonIgnore
	private Product product; // 产品

	@Column
	private Integer holdingTime; // 持有时间，单位天
	
	@Column
	private BigDecimal interestRate; // 年化利率
	
	@Column
	private Date dueDate; // 到期日，计息最后一天
	
	@Column
	private Date redemptionStartTime; // 赎回开始时间
	
	@Column
	private Date redemptionEndTime; // 赎回结束时间
	
	private int stage; //阶段
	
	private boolean last; //是否最后一个阶段
	
	public BigDecimal getFinalInterestRate(){
		BigDecimal extra = getProduct().getBonusRate()!=null ? getProduct().getBonusRate() : new BigDecimal(0);
		return getInterestRate().add(extra);
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Integer getHoldingTime() {
		return holdingTime;
	}

	public void setHoldingTime(Integer holdingTime) {
		this.holdingTime = holdingTime;
	}

	public BigDecimal getInterestRate() {
		return interestRate;
	}

	public void setInterestRate(BigDecimal interestRate) {
		this.interestRate = interestRate;
	}

	public Date getDueDate() {
		return dueDate;
	}

	public void setDueDate(Date dueDate) {
		this.dueDate = dueDate;
	}

	public Date getRedemptionStartTime() {
		return redemptionStartTime;
	}

	public void setRedemptionStartTime(Date redemptionStartTime) {
		this.redemptionStartTime = redemptionStartTime;
	}

	public Date getRedemptionEndTime() {
		return redemptionEndTime;
	}

	public void setRedemptionEndTime(Date redemptionEndTime) {
		this.redemptionEndTime = redemptionEndTime;
	}

	public int getStage() {
		return stage;
	}

	public void setStage(int stage) {
		this.stage = stage;
	}

	public boolean isLast() {
		return last;
	}

	public void setLast(boolean last) {
		this.last = last;
	}
}
